#ifndef UHM_MAT_EXTENSION_LDL_INCPIV_HXX_
#define UHM_MAT_EXTENSION_LDL_INCPIV_HXX_

namespace uhm {
  
  // Basic LDL incpiv...
  template<class A_, class B_>
  class LDL_incpiv_ : public LDL_piv_<A_,B_> {
  private:
  protected:
  public:

    LDL_incpiv_() : LDL_piv_<A_,B_>() { }
    LDL_incpiv_(Int_ type, Int_ uplo, Int_ sym,
                Int_ mt, Int_ mb,
                Int_ rhs, Int_ blk) 
      : LDL_piv_<A_,B_>(type, mt, mb, rhs, blk) { }
    LDL_incpiv_(Int_ type, 
                Int_ mt, Int_ mb, 
                Int_ rhs, 
                Int_ blk)  
      : LDL_piv_<A_,B_>(type, mt, mb, rhs, blk) { }
    
    LDL_incpiv_(const LDL_incpiv_ &b) : LDL_piv_<A_,B_>(b) { }

    using LDL_piv_<A_,B_>::get_leading_flop;
    using LDL_piv_<A_,B_>::update;
    using LDL_piv_<A_,B_>::decompose;
    using LDL_piv_<A_,B_>::solve_1_x;
    using LDL_piv_<A_,B_>::solve_2_x;
    using LDL_piv_<A_,B_>::solve_1_r;
    using LDL_piv_<A_,B_>::solve_2_r;

    virtual Int_ decompose() {
      if (this->get_mt()) {
        ldl_incpiv( Mat_Base_::LOWER_TRIANGULAR, this->_ATL, this->_P );
        this->_ATL.hermitianize();
        apply_diag_scal( Mat_Base_::LEFT, Mat_Base_::NO_CONJUGATE,
                         Mat_Base_::UPPER_TRIANGULAR,
                         this->_ATL );
      }

      this->update();

      return true;
    }
  };

}

#endif
